package com.thinking.in.spring.bean.factory;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author : zjj
 * @date : 2021/12/28 17:30
 */
public class DefaultUserFactory implements UserFactory, InitializingBean, DisposableBean {

    /**
     * java 的标准注解 ：实现 bean的初始化
     */
    @PostConstruct
    public void init(){
        System.out.println("userFactory 初始化中 ");
    }

    public  void initFactory(){
        System.out.println("自定义初始化方法 initUserFactory() : userFactory 正在初始化");

    }


    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("InitializingBean  : userFactory 正在初始化");

    }

    @PreDestroy
    public void preDestroy(){
        System.out.println("@PreDestroy : bean 的销毁");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("DisposableBean : bean 的销毁");
    }

    public void doDestroy(){
        System.out.println("自定义销毁方法 : bean 的销毁");
    }


    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("当前对象正在被回收 。。。。。。");
    }
}
